﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentValidation;
using FluentValidation.Results;
using Microhard.Permission.Interface;
using Microhard.Core;

namespace Microhard.Permission.Validator
{
    public class GroupValidator : AbstractValidator<Microhard.Permission.Models.Group>
    {
        public GroupValidator()
        {
            IGroup ig = IoC.Resolve<IGroup>();
            RuleSet("Insert", () =>
            {
                RuleFor(u => u.Name).NotEmpty().WithMessage(MsgForPermission.NeedGroupName).When(u=>u.ID == Guid.Empty);
                RuleFor(u => u.Name).Length(1, 10).WithMessage(MsgForPermission.MaxLenOfGroupName).When(u => u.ID == Guid.Empty);

                //Custom(u =>
                //{
                //    if (u.ID == Guid.Empty)
                //    {
                //        if ()
                //        {
                //            return new ValidationFailure("ManagerName", MsgForPermission.NeedGroupManager);
                //        }
                //    }
                //    return null;
                //});
            });
        }
    }
}
